//
// Created by vcq on 21/2/23.
//
#pragma once
struct _plan_goal {
    int id;
    int _goal_id;
    int _plan_id;
    double per;
    string note;
};
REFLECTION(_plan_goal, id, _goal_id, _plan_id,note)

json mgetPlanGoal(basic_string_view<char> id,basic_string_view<char> _plan_id,basic_string_view<char> _goal_id){
    string sql="select * from `_plan_goal` where 1=1 ";
    if (!id.empty()) {
        sql += "and id =";
        sql += id;
    }
    if (!_plan_id.empty()) {
        sql += "and _plan_id =";
        sql += _plan_id;
    }
    if (!_goal_id.empty()) {
        sql += "and _goal_id =";
        sql += _goal_id;
    }
    Dao dao;
    auto v = dao.query<_plan_goal>(sql);
    nlohmann::json article_list,ret,item;
    for (auto& o : v) {
        item["id"]=o.id;
        item["_goal_id"]=o._goal_id;
        item["_plan_id"]=o._plan_id;
        item["per"]=o.per;
        item["note"]=o.note;
        article_list.push_back(item);
    }
    ret["code"]=0;
    ret["count"]=article_list.size();
    ret["data"]=article_list;
    return ret;
}

